/********************************************************************
	Rhapsody	: 7.5 
	Login		: kbe
	Component	: DefaultComponent 
	Configuration 	: CodeConfig
	Model Element	: Patient
//!	Generated Date	: Thu, 27, Sep 2012  
	File Path	: DefaultComponent\CodeConfig\Patient.cpp
*********************************************************************/

//## auto_generated
#include "Reactor.h"
//## auto_generated
#include "Patient.h"
//## package Default

//## class Patient
Patient::Patient(Reactor * reactor) {
    //#[ operation Patient(Reactor *)
    //#[ operation LogEvent(Reactor*,SOCK_Stream)
    itsReactor = reactor;
    //#]
}

void Patient::getPatientInfo(char* cpr) {
    //#[ operation getPatientInfo(char*)
    if (strlen(cpr) < sizeof(buffer_))
    {
    	strcpy(buffer_, cpr);  
    	getPeer_stream_()->send_n(buffer_, sizeof(buffer_), 0);
    }
    //#]
}

int Patient::handleEvent(HANDLE h, Event_Type& et) {
    //#[ operation handleEvent(HANDLE,Event_Type)
    if (et == type) {
    	int n = getPeer_stream_()->recv_n(buffer_, sizeof(buffer_), 0);
    	if (n > 0) { 
    		PatientAction();
    	}
    }
    return 0;
    //#]
}

void Patient::PatientAction() {
    //#[ operation PatientAction()
    printf("Patient: %s\n", buffer_);
    //#]
}

Patient::Patient() {
}

Patient::~Patient() {
}

char Patient::getBuffer_(int i1) const {
    return buffer_[i1];
}

void Patient::setBuffer_(int i1, char p_buffer_) {
    buffer_[i1] = p_buffer_;
}

/*********************************************************************
	File Path	: DefaultComponent\CodeConfig\Patient.cpp
*********************************************************************/
